//var UID,SOCK 
//function	send	Getuion_Oline	Getuion_sock_Oline	Getuion_all	Print	execSQL		file_ReadLine
 console_type_default = 0
 console_type_error = 1
 console_type_console=3
 console_type_debug=2
 console_type_application=4
 console_type_hidedate=16
var name="relay";//必须与文件名相同
function Getinfo(){
	Print(4,"Load relay is ok")
	return JSON.stringify({
		"describe":"relay system",
		"version":"1.0.0.0",
		"title":"Relay os",
		"Enable":"1"
	})
}
function Init(){//每一次断开设备重新连接都会执行
	Print(console_type_debug,"初始化设备中")
	str="turnon=function()gpio.write(pin,gpio.LOW);turn=1;end;turnoff=function()gpio.write(pin,gpio.HIGH);turn=0;end"
	str=str+';DLED=false;if(turn==nil)then turn=0;turnoff();end;HRV=function(data)h=string.sub(data,1,1) if(h=="\1")then send(turn) end end HRV("\1");'
	
	exec(str)
	Sleep(100)//避免数据连串
	Send_sign_Sync()
}
function Onmessage(lx,data,sock_){
	//data 存放的是数据，是以[]byte数组存放的
	//lx   0 单片机    1客户端
	if(data.length>0){x=parseInt(String.fromCharCode(data[0]))}else{x=0}
	
	if(lx==1){
		
		Print(console_type_debug,x)
		if(x==0){
			Updata("0")
			exec("turnoff()")
			Print(console_type_debug,"关闭设备")
		}else{
			Updata("1")
			exec("turnon()")
			Print(console_type_debug,"开启设备")
		}
	}else if(lx==0){//单片机消息
		//Print(0,x,data[0])
		Updata(x)
		//if(x==1)
	}
}
function Send_sign_Sync(){/*Pop("\1")*/exec("\6\1");Print(console_type_default,"show sign sync ")}
//init()